import javax.swing.*;

public class JButtonTest {
    public static void main(String[] args) {
        JFrame frame=new JFrame("amoy");
        frame.setSize(300,150);

        frame.setLayout(null);
        JButton button=new JButton("OK");
        button.setSize(100,50);
        button.addActionListener(e -> {
            JOptionPane.showMessageDialog(null,"被点击了","提示",JOptionPane.INFORMATION_MESSAGE);
        });
        frame.add(button);

        frame.setVisible(true);
    }
}
